package leetcode;

public class ValidPalindrome {

	public static void main(String[] args) {
		System.out.println('a' + 1);
    	System.out.println('A' + 1);
	}
	public boolean isPalindrome(String s) {
        if(s == null || s.length() <= 0){
            return true;
        }
        char[] chas = s.toCharArray();
        int validLength = 0;
        for(int i = 0; i < chas.length; i++){
            if(chas[i] >= 'a' && chas[i] <= 'z'){
            	chas[validLength++] = chas[i];
            }else if(chas[i] >= 'A' && chas[i] <= 'Z'){
            	chas[validLength++] = (char)(chas[i] + 32);
            }else if(chas[i] >= '0' && chas[i] <= '9'){
            	chas[validLength++] = chas[i];
            }
        }
        int j = validLength - 1;
        for(int i = 0; i < validLength / 2; i++){
        	if(chas[i] != chas[j--]){
        		return false;
        	}
        }
        return true;
    }
}
